/*
 * This file (AkColorMngrStandard.java) is protected by the GNU GPL licence (v2). 
 * Please read the license.txt attached for further informations. 
 * 
 */

package alkwarel.colors;

import java.awt.Color;
import java.awt.Dialog.ModalityType;

import alkwarel.gui.AkColorDlg;
import artx.utils.AxLog;

/**
 * A standard color manager (only one color in its palette, using a standard
 * RGB/HSV input).
 * 
 * @author Xavier Gouchet
 * 
 */
public class AkColorMngrStandard extends AkColorManager {

	private int color = -1;

	/**
	 * @see alkwarel.colors.AkColorManager#GetColor()
	 */
	public int GetColor() {
		return this.color;
	}

	/**
	 * @see alkwarel.colors.AkColorManager#ShowGUIDlg()
	 */
	public void ShowGUIDlg() {
		// TODO reset the dialog with the current color
		AkColorDlg colorsDlg = new AkColorDlg(null);
		colorsDlg.setModalityType(ModalityType.APPLICATION_MODAL);
		colorsDlg.setVisible(true);
		if (colorsDlg.ExitStatus() == 0) {
			Color col = colorsDlg.GetColor();
			this.color = (col.getAlpha() << 24) | (col.getRed() << 16)
					| (col.getGreen() << 8) | col.getBlue();
			AxLog
					.Debug("AkColorMngrStandard::ShowGUIDlg =>> new color selected : 0x"
							+ Integer.toHexString(this.color));
			AxLog.Info("New color selected : 0x"
					+ Integer.toHexString(this.color));
		}
	}

}
